package com.hbusa.cotroller.type;


import com.hbusa.dto.TbCategory;
import com.hbusa.service.service.impl.CategoryServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/doCategoryModify")
public class categoryModify extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setCharacterEncoding("utf-8");
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;utf-8");

        String cat_id = req.getParameter("cat_id");
        String cat_name = req.getParameter("cat_name");

        System.out.println(cat_id);
        System.out.println(cat_name);

        TbCategory category = new TbCategory();
        category.setCatName(cat_name);
        category.setCatId(Long.parseLong(cat_id));
        CategoryServiceImpl categoryService = new CategoryServiceImpl();

        boolean b = categoryService.doModify(Long.parseLong(cat_id),category);
        System.out.println(b);
        resp.sendRedirect("/doCategoryFindAll");


    }
}
